<!DOCTYPE html>
<!--

// Copyright 2011 Traceur Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

-->
<html>
<head>
<title></title>
<script src="../../../third_party/closure-library/closure/goog/base.js"></script>
<script>
// NOTE: base.js and all goog.require statements must be in JS script blocks
// NOTE: because they use document.write to add new script tags in place
goog.require('goog.testing.jsunit');
</script>
<script src="../../../bin/traceur.js"></script>
</head>
<body>
<script type="text/expected-result">
var $__toObject = function(value) {
  if (value == null) throw TypeError();
  return Object(value);
}, $__spread = function() {
  var rv = [], k = 0;
  for (var i = 0; i < arguments.length; i++) {
    var value = $__toObject(arguments[i]);
    for (var j = 0; j < value.length; j++) {
      rv[k++] = value[j];
    }
  }
  return rv;
};
var a = $__spread([0, 1]);
var b = $__spread(a, [2]);
</script>
<script>

var ProjectWriter = traceur.outputgeneration.ProjectWriter;

traceur.options.reset(true);
traceur.options.spread = true;

function normalize(s) {
  return s.trim().replace(/\s+\n/g, '\n');
}

function testTwoProprams() {
  var url = location.href;
  var project = new traceur.semantics.symbols.Project(url);

  var sourceA = 'var a = [...[0, 1]];'
  var fileA = new traceur.syntax.SourceFile('a', sourceA);
  project.addFile(fileA);

  var sourceB = 'var b = [...a, 2];'
  var fileB = new traceur.syntax.SourceFile('b', sourceB);
  project.addFile(fileB);

  var reporter = new traceur.util.ErrorReporter();

  var res = traceur.codegeneration.Compiler.compile(reporter, project, false);

  var expectedResult = normalize(
      document.querySelector('[type="text/expected-result"]').textContent);
  var actualResult = normalize(ProjectWriter.write(res));

  assertEquals(expectedResult, actualResult);
}

</script>
</body>
</html>
